package com.fcy.teamwork.security.environment.checknode

import android.content.Context
import com.fcy.teamwork.base.log
import com.fcy.teamwork.security.environment.SecurityCheckNode

const val XPOSED_BRIDGE = "de.robv.android.xposed.XposedBridge";

class XposedCheck : SecurityCheckNode {
    class XposedException : Exception()

    override fun isSecurity(context: Context?): Boolean {
        runCatching {
            throw XposedException()
        }.exceptionOrNull()?.also {
            for (stackTraceElement in it.stackTrace) {
                if (stackTraceElement.className.contains(XPOSED_BRIDGE)) {
                    log("Xposed 检测未通过")
                    return false
                }
            }
        }
        return true
    }
}